﻿using System;
using System.Globalization;
using System.Windows.Data;

namespace TallyJ1Announcer.Converters
{
	[ValueConversion(typeof(double), typeof(double))]
	public class RatioConverter : IValueConverter
	{
		public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
		{
			var input = (double)value;
			var ratio = Double.Parse(parameter.ToString());

			return input * ratio;
		}

		public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
		{
			var input = (double)value;
			var ratio = (double)parameter;

			return input / ratio;
		}
	}
}